import java.io.*;
import java.util.Set;


public class ManagerNew {
	private final File inputFile;
	private final File outputFile;
	private Set<String> stringSet;
	String[] charsetsToBeTested = {"UTF-8", "windows-1253", "ISO-8859-7", "cp1251"};


	public ManagerNew(File inputFile, File outputFile) {
		this.inputFile = inputFile;
		this.outputFile = outputFile;
	}

	public void startParsing() throws IOException {

		stringSet = DataReaderWriterValidator.readFromStream(new FileInputStream(inputFile), new CharsetDetector().detectCharset(inputFile, charsetsToBeTested));
		if ( ! outputFile.exists() ) {
			outputFile.createNewFile();
		}
		DataReaderWriterValidator.writeToStream(new FileOutputStream(outputFile, true), TextParserNew.parseWords(stringSet));
	}
}
